<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
	
	<link rel="stylesheet" type="text/css" href="../../css/base.css" />
	<link id="easyuiTheme"  rel="stylesheet" type="text/css" href="../../easy-ui/themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="../../easy-ui/themes/icon.css">
	<script type="text/javascript" src="../../easy-ui/jquery.min.js"></script>
	<script type="text/javascript" src="../../easy-ui/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="../../easy-ui/easyui-lang-zh_CN.js"></script>
	<script type="text/javascript" src="../../js/base.js" ></script>
	<script type="text/javascript" src="../../js/jquery.form.js"></script>
	<!-- ue editor begin -->
	
<!-- 	<script type="text/javascript" charset="utf-8" src="../../js/plugin/ueditor1_4_3/ueditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="../../js/plugin/ueditor1_4_3/ueditor.all.min.js"> </script>
    建议手动加在语言，避免在ie下有时因为加载语言失败导致编辑器加载失败
    这里加载的语言文件会覆盖你在配置项目里添加的语言类型，比如你在配置项目里配置的是英文，这里加载的中文，那最后就是中文
    <script type="text/javascript" charset="utf-8" src="../../js/plugin/ueditor1_4_3/lang/zh-cn/zh-cn.js"></script>
 -->	<!-- ue end -->
      <style type="text/css">
    body,html,div,ul,li,span,p,input,form,label,a,img,em,dl,dt,dd,textarea,h3,table,th,td,tr{margin:0;padding:0;font-size:12px;font-family:"'微软雅黑 ', '微软雅黑'"!important;list-style:none;font-style:normal;word-break: break-all;word-wrap: break-word;}
	input[type="text"]::-ms-clear{display:none;}
	input[type="radio"],input[type="checkbox"]{cursor:pointer;vertical-align:middle;}
	.fl{float:left;}
	.fr{float:right;}
	.oh{overflow:hidden;}
	.table-gray{background: #f8f8f8;text-align: right;line-height: 20px;}
	.myTable{ padding: 30px; border: 1px solid #c9c9c9;}
	.td-span{padding-left: 15px;}
	.myTable>table{width: 100%; border-top: 1px solid #c9c9c9; border-right: 1px solid #c9c9c9;}
	.myTable>table>tbody>tr{overflow: hidden;}
	.myTable>table>tbody>tr>td{border-left: 1px solid #c9c9c9;border-bottom: 1px solid #c9c9c9;padding:10px;}
	.myTable>table>tbody>tr>td>input{height: 24px;width: 80px;}
	.myTable>table>tbody>tr>td>select{width: 100%;}
	.myTable>table>tbody>tr>td>textarea{width: 100%;}
	.td-sec{margin: 8px 8px;}
	.td-sec>span{padding-right: 8px;}
	.td-sec>span>input{width: 60px;}
	.td-a{display: block;background: #0d73b4;width: 75px;height: 24px;line-height: 24px;text-align: center;
	border-radius: 5px;-moz-border-radius: 5px;-ms-border-radius: 5px;-webkit-border-radius: 5px;-o-border-radius:5px;
	color: #fff}
	.td-third>textarea{width: 85%; height: 80px;margin-left: 8px;}
	.table-solo{overflow: hidden;text-align: center;}
	.table-solo>td{border: 1px solid #C9C9C9;padding: 5px;}
	    
    
    </style>
</head>


<body class="easyui-layout" data-options="fit:true" style="overflow:hidden;">
		<!-- 表单提交-->
		<div data-options="region:'south',border:false," style="height:40px;text-align:center;">

			  <table style="width:100%;margin-top:8px;" >
							<tr>
							<td style="align:center;">
								<a href='javascript:void(-1);' onclick="baseFormSubmit();"; class="easyui-linkbutton" data-options="iconCls:'icon-save'">确定</a>&nbsp;&nbsp;
								<a href='javascript:void(-1);' onclick="baseFormReset();";  class="easyui-linkbutton" data-options="iconCls:'icon-back'">重置</a>
							</td>
							</tr>
				</table>
		</div>
		<div data-options="region:'center',border:true,">
		
	<!-- the baseForm start  -->
<!-- 	<form id="myform" action="" method="post" enctype="multipart/form-data">
		<input type="file" id="file" name="file" >
		<input type="hidden" id="fileShopId" name="shopId" >
		<input type="hidden" id="fileUserId" name="userId" >
		<input type="button" value="导入" onclick="ajaxSubmitForm()">
	</form> -->
	
	~~~~~~~~~~~~~~~~~~~~~~~~~
	
	<form id="baseForm" name="baseForm" method="post" target="hiddenFrame" style="margin:0px;padding:0px;overflow:hidden;" enctype="multipart/form-data">
		<input id="id" name="id" type="hidden" /> 
		<input  name="forceUpdateFlag"  id="forceUpdateFlag" type="hidden" ></input>
		<input  name="onFlag"  id="onFlag" type="hidden" ></input>
		
		<div class="myTable">
				  <table cellpadding="0" cellspacing="0">
				    <tbody>
				      <tr>
				        <td class="table-gray" width="10%" >类型：</td>
				        <td colspan="3">
				        <input  name="clientType" id="clientType"  type="text" style="width: 100%;" class="easyui-validatebox textbox" data-options="required:true,novalidate:true">
				        </td>
				        
				      </tr>
				      
				      <tr>
				        <td class="table-gray" width="10%" >最新版本：</td>
				        <td colspan="3">
				        <input  name="lastVersion" id="lastVersion"  type="text" style="width: 100%;" class="easyui-validatebox textbox" >
				        </td>
				      </tr>
				     
				        <tr>
				        <td class="table-gray"> 安装包文件：</td>
				        <td colspan="3">
				       <!-- 文件上传预览控件 开始 -->
						<input type="file" id="file" name="file" >
						<!-- 文件上传预览控件 结束 -->
				        </td>
				      </tr>
				      <tr>
						<td  class="table-gray">
						更新状态：
						</td>
						 <td class="data-table-input" colspan=2 >
						<input class="easyui-combobox" id="updateStatus_combobox"  data-options="required:true,valueField:'id',textField:'text',editable:false," style="width:100%;"/>
						</td>
					  </tr>
					  <tr>
						<td  class="table-gray">
						开启状态：
						</td>
						 <td class="data-table-input" colspan=2 >
						<input class="easyui-combobox" id="openStatus_combobox"  data-options="required:true,valueField:'id',textField:'text',editable:false," style="width:100%;"/>
						</td>
					   </tr>
				       <tr>
				         <td class="table-gray">更新地址:</td>
				        <td colspan="3">
				        	<input  name="updateUrl" id="updateUrl"  type="text" style="width: 100%;" class="easyui-validatebox textbox" data-options="required:true,novalidate:true">
				        </td>
				      </tr>
				    </tbody>
				  </table>
				</div>
		</form>
			
			<!-- the dataForm end  -->
			
		</div>
	
	

	<script type="text/javascript">

	var uesummary=null;
	var ueactivitySchedule=null;
	var ueactivityAddressMap=null;
		function initPage(id){
			 parent.showProgressing();
			 document.getElementById('id').value=eval('parent.parent.'+getQueryString('targetFrame')+'.mainFrame_id.selections[0].id');
			 parent.showProgressing();
			 sendRequestAjax('../../version/initUpdateVersionInfo.do?responseFunction=initUpdate&',initUpdate);
		}
		
		function updateSave(responseResult){
		    executeWindowCallback( {});
			
			if(responseResult.slide_msg_key==1){
				parent.parent.showSlideMsg(responseResult.slide_msg_message_key);
			}
			parent.closeProgressing();
			
			//关闭当前tab
 			var currentTab =parent.parent.$('#tabs').tabs('getSelected');
            var currtab_title = currentTab.panel('options').title;
            var currtab_id = currentTab.panel('options').id;
            if(currtab_id!='index_welcome_id'){
           		 parent.parent.$('#tabs').tabs('close', currtab_title);
            }
		}
		
		function checkApk() {
			var fileName = $('#file').val();
			if (fileName === '') {
				alert('请选择文件');
				return false;
			}
			var fileType = (fileName.substring(fileName.lastIndexOf(".") + 1,
					fileName.length)).toLowerCase();
			if (fileType !== 'apk') {
				alert('文件格式不正确，请选择apk文件！');
				return false;
			}
			return true;
		}
		
		function ajaxSubmitForm() {
			var option = {
				url :  "../../version/updateVersionInfo.do",
				type : 'POST',
				contentType: "application/json",
				dataType : 'json',
				headers : {
					"ClientCallMode" : "ajax"
				}, //添加请求头部
				success : function(result) {
					if (result != '') {
						alert(result.data);
						var currentTab =parent.parent.$('#tabs').tabs('getSelected');
			            var currtab_title = currentTab.panel('options').title;
			            var currtab_id = currentTab.panel('options').id;
			            if(currtab_id!='index_welcome_id'){
			           		 parent.parent.$('#tabs').tabs('close', currtab_title);
			            }
					} else {
						alert('文件内容格式错误');
					}
				},
				error : function(data) {
					alert("导入失败！");
				}
			};
			if (checkApk()) {
				$("#baseForm").ajaxSubmit(option);
			}
			return false; //最好返回false，因为如果按钮类型是submit,则表单自己又会提交一次;返回false阻止表单再次提交
		}
		window.onload=function(){
			//uesummary= UE.getEditor('summary');
			//uesummary.setContent('', true);
			//ueactivitySchedule= UE.getEditor('activitySchedule');
			//ueactivitySchedule.setContent('', true);
			//ueactivityAddressMap= UE.getEditor('activityAddressMap');
			//ueactivityAddressMap.setContent('', true);
			initPage();
		}
		
		var responseResultPage;
		function initUpdate(responseResult){
			$("#id").val(responseResult.data.id);
			$("#forceUpdateFlag").val(responseResult.data.forceUpdateFlag);
			$("#clientType").val(responseResult.data.clientType);
			$("#onFlag").val(responseResult.data.onFlag);
			$("#updateUrl").val(responseResult.data.updateUrl);
			$("#lastVersion").val(responseResult.data.lastVersion);
			
			parent.closeProgressing();  
			//setFormDefault(responseResult); 
			$('#updateStatus_combobox').combobox({
		  		data: [{id:'2',text:'选择更新'},{id:'1',text:'强制更新'}],
		  		value:responseResult.data.forceUpdateFlag,
		  		//width:parseInt($("#table_input_base")[0].offsetWidth)+2,
		  		onSelect: function(record){
			  			document.getElementById("forceUpdateFlag").value=record.id;
				}
			});
			$('#openStatus_combobox').combobox({
		  		data: [{id:'0',text:'未开启'},{id:'1',text:'开启'}],
		  		value:responseResult.data.onFlag,
		  		//width:parseInt($("#table_input_base")[0].offsetWidth)+2,
		  		onSelect: function(record){
			  			document.getElementById("onFlag").value=record.id;
				}
			});
			/* if(responseResult.entity.attachmentUrl!=''){
				document.getElementById("viewPic").innerHTML="<img src='"+responseResult.entity.attachmentPrefix+responseResult.entity.titleImg+"' style='height:80px;'></img>";	
			}else{
				document.getElementById("viewPic").innerHTML="";
			} */
		}
		
		
	
		//form表单 提交 重置 提交后响应处理 ----------------
		function  baseFormReset(){
			
			 initUpdate(responseResultPage);
			
		}
		
		function baseFormSubmit(){
			var flag= $("#baseForm").form('enableValidation').form('validate');
		    if(flag){
		    	/* if(uesummary.getContent()==null || uesummary.getContent()==''){
		    		parent.$.messager.alert('消息提示','活动概要不能为空','error');
		    		return;
		    	} */
		    	/* if(ueactivitySchedule.getContent()==null || ueactivitySchedule.getContent()==''){
		    		parent.$.messager.alert('消息提示','活动日程不能为空','error');
		    		return;
		    	}
		    	if(ueactivityAddressMap.getContent()==null || ueactivityAddressMap.getContent()==''){
		    		parent.$.messager.alert('消息提示','活动地点地图不能为空','error');
		    		return;
		    	} */
				parent.showProgressing();
				//sendRequestAjax('../../version/updateVersionInfo.do?responseFunction=updateSave',updateSave)
				ajaxSubmitForm();
		    }	
		}
		//form表单 提交 重置 提交后响应处理结束 ------------
		function baseFormFileUp(){
			parent.showProgressing();
	//		sendFileUploadRequestAjax('../../contentFileUp/fileUp.do?responseFunction=upFileSuc',upFileSuc,'upFile');
			sendFileUploadParam('../../contentFileUp/fileUp.do?responseFunction=upFileSuc',{restrictType:'0',restricts:[{value:'jpg'},{value:'gif'},{value:'png'},{value:'bmp'}]},upFileSuc,'upFile');
		}
		
		function upFileSuc(responseResult){
			document.getElementById("viewPic").innerHTML="";
			document.getElementById("titleImg").value=responseResult.attachmentUrl;
			document.getElementById("viewPic").innerHTML="<img src='../../"+responseResult.attachmentUrl+"' style='height:80px;'></img>";	
			parent.closeProgressing();
		}
		//easyui日期控件  时间格式转化
		function myformatter(date){
			var y = date.getFullYear();
			var m = date.getMonth()+1;
			var d = date.getDate();

			var h = date.getHours();
			var mm = date.getMinutes();
			//var s = date.getSeconds();
			return y+'-'+(m<10?('0'+m):m)+'-'+(d<10?('0'+d):d)+' '+(h<10?('0'+h):h)+':'+(mm<10?('0'+mm):mm)/* +':'+(s<10?('0'+s):s) */;
		}
		function myparser(s){
			if (!s) 
				return new Date();
			var dm = s.split(' ')
			var ss = (dm[0].split('-'));
			var y = parseInt(ss[0],10);
			var m = parseInt(ss[1],10);
			var d = parseInt(ss[2],10);
			
			var h, mm, s;
			
			if(dm[1] !=null && dm[1] !='' && dm[1] != undefined){
				var hms = (dm[1].split(':'));
				h =  parseInt(hms[0],10);
				mm =  parseInt(hms[1],10);
				//s =  parseInt(hms[2],10);
			}
			
			if (!isNaN(y) && !isNaN(m) && !isNaN(d)){
				return new Date(y,m-1,d,h,mm/* ,s */);
			}else{
				return new Date();
			}
		}
				
	</script>


	

</body>
</html>